<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Kriging Library: covars Module Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<script src="../mathjax/MathJax.js">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Kriging Library
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="annotated.html"><span>Data&#160;Types&#160;List</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Data&#160;Types</span></a></li>
      <li><a href="functions.html"><span>Data&#160;Fields</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a>  </div>
  <div class="headertitle">
<div class="title">covars Module Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="covars" -->
<p><a href="modulecovars-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">real(8) function&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#a81f313ed8e3c0ce673153e5949fefeb5">covar1d</a> (X, Xt, theta)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function used to calculate the one dimensional covariance functions used to construct the multidimensional functions.  <a href="#a81f313ed8e3c0ce673153e5949fefeb5"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">real(8) function&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#af8df26f523fb00b229c1d37818ee3187">dcovar1d</a> (X, Xt, theta)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function used to calculate the derivative of the one dimensional covariance functions with respect to the first coordinate.  <a href="#af8df26f523fb00b229c1d37818ee3187"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">real(8) function&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#a35f54882bfdaa11ca28b8ea391c5fb8c">d2covar1d</a> (X, Xt, theta)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Function used to calculate the second derivative of the one dimensional covariance functions with respect to the second coordinate.  <a href="#a35f54882bfdaa11ca28b8ea391c5fb8c"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">subroutine&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#adb9de23578a8355229466a5dcd8e26e6">covarfunc</a> (ndim, X, Xt, theta, k)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Subroutine for computing the multidimensional covariance between two data points.  <a href="#adb9de23578a8355229466a5dcd8e26e6"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">subroutine&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#a0b0ed77b6fba9f79673cfa398b77b8d3">dcovarfunc</a> (ndim, X, Xt, theta, dk)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Subroutine for computing the gradient of the multidimensional covariance function.  <a href="#a0b0ed77b6fba9f79673cfa398b77b8d3"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">subroutine&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#a34ae1208b87dd5a6ce817bfa04c127dc">d2covarfunc</a> (ndim, X, Xt, theta, d2k)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Subroutine for computing the Hessian of the multidimensional covariance function. The second derivative is performed with respect to the second coordinate.  <a href="#a34ae1208b87dd5a6ce817bfa04c127dc"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">integer&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#aa9afe235deb03daa3ab99562f273a049">covarflag</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">real(8), parameter&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#a13b8005ed6d342aa9ffef7e63ae87ca2">root3</a> = sqrt(3.d0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">real(8), parameter&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#ad0ecb51a9375ad09cba6e8014ba62eac">root5</a> = sqrt(5.d0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">real(8), parameter&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcovars.html#ac23ea8267361ac7e7127b192e9d6b7a2">third</a> = 1.D0/3.D0</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock">
<p>Definition at line <a class="el" href="covars_8f90_source.html#l00012">12</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>
</div><hr/><h2>Member Function/Subroutine Documentation</h2>
<a class="anchor" id="a81f313ed8e3c0ce673153e5949fefeb5"></a><!-- doxytag: member="covars::covar1d" ref="a81f313ed8e3c0ce673153e5949fefeb5" args="(X, Xt, theta)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">real(8) function covars::covar1d </td>
          <td>(</td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>Xt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function used to calculate the one dimensional covariance functions used to construct the multidimensional functions. </p>
<p>This function calculates the one dimensional Matern function with three possible values the parameter \( \nu \) (specified with the variable <em>covarflag</em>). The three possible functions are given as: </p>
<p class="formulaDsp">
\[ k(x,x&#39;) = \begin{cases} e^{-r} &amp; \text{for $\nu = 1/2$,} \\\ \left(1 + \sqrt{3} r \right) e^{-\sqrt{3} r} &amp; \text{for $\nu = 3/2$,} \\\ \left(1 + \sqrt{5} r+ \frac{5}{3} r^{2} \right) e^{-\sqrt{5} r} &amp; \text{for $\nu = 5/2$,} \end{cases}\]
</p>
<p> where \(r\) is defined as: </p>
<p class="formulaDsp">
\[ r = \bigg \vert \frac{X - X&#39;}{\theta} \bigg \vert \]
</p>
 <dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood <br/>
 Department of Mechanical Engineering <br/>
 University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 17, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> X </b>: Coordinate of the first point </td></tr>
    <tr><td class="paramname">in)</td><td><b> Xt</b>: Coordinate of the second point </td></tr>
    <tr><td class="paramname">in)</td><td><b> theta</b>: Length scale in the dimension </td></tr>
    <tr><td class="paramname">in)</td><td><b>covarflag</b>: Flag to govern which covariance function is used (stored as global variable in this module) <br/>
 <ul>
<li>
covarflag==0 Uses Matern function with \(\nu=1/2\) </li>
<li>
covarflag==1 Uses Matern function with \(\nu=3/2\) </li>
<li>
covarflag==2 Uses Matern function with \(\nu=5/2\) </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">covar1d</td><td>the 1-D Covariance value </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00040">40</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="adb9de23578a8355229466a5dcd8e26e6"></a><!-- doxytag: member="covars::covarfunc" ref="adb9de23578a8355229466a5dcd8e26e6" args="(ndim, X, Xt, theta, k)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">subroutine covars::covarfunc </td>
          <td>(</td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ndim</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>Xt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(out)&#160;</td>
          <td class="paramname"><em>k</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Subroutine for computing the multidimensional covariance between two data points. </p>
<p>Multidimensional covariance is built up using a tensor product of 1 dimensional covariance functions: </p>
<p class="formulaDsp">
\[ k(\vec{X},\vec{X}&#39;; \theta) = \prod_{i}^{d} k_{i}\left(\bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert\right)\]
</p>
<p> where \(D\) is the dimension of the problem. The 1-D covariance functions are defined in function covar1d </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood Department of Mechanical Engineering University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 3, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> ndim </b>: The dimension of the problem </td></tr>
    <tr><td class="paramname">in)</td><td><b> X </b>: Coordinates of the first point (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> Xt </b>: Coordinates of the second point (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> theta </b>: Length scale in each dimension </td></tr>
    <tr><td class="paramname">out)</td><td><b> k </b>: Covariance value </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00164">164</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="a35f54882bfdaa11ca28b8ea391c5fb8c"></a><!-- doxytag: member="covars::d2covar1d" ref="a35f54882bfdaa11ca28b8ea391c5fb8c" args="(X, Xt, theta)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">real(8) function covars::d2covar1d </td>
          <td>(</td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>Xt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function used to calculate the second derivative of the one dimensional covariance functions with respect to the second coordinate. </p>
<p>This function calculates the second derivative of the one dimensional Matern function with three possible values the parameter \( \nu \) (specified with the variable <em>covarflag</em>). The second derivative of interest is the derivative of the result of <em>dcovar1d</em> with respect to the argument <em>Xt</em>. This derivative is required for the covariance between derivative values: </p>
<p class="formulaDsp">
\[ cov(\frac{d y}{d x}, \frac{d y&#39;}{d x}) = \frac{d^{2}}{dx dx&#39;} k(X,X&#39;,\theta) \]
</p>
<p> The practical result of differeniating with repsect to the second argument is that an extra negative sign appears. Hence, the second derivative of the Matern functions with respect to \(r\) can be calculated and an additional negative sign can be applied to the result to yield the required derivative value. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood <br/>
 Department of Mechanical Engineering <br/>
 University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 17, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> X </b>: Coordinate of the first point </td></tr>
    <tr><td class="paramname">in)</td><td><b> Xt</b>: Coordinate of the second point </td></tr>
    <tr><td class="paramname">in)</td><td><b> </b>: Length scale in the dimension </td></tr>
    <tr><td class="paramname">in)</td><td><b>covarflag</b>: Flag to govern which covariance function is used (stored as global variable in this module) <br/>
 <ul>
<li>
covarflag==0 Uses Matern function with \(\nu=1/2\) </li>
<li>
covarflag==1 Uses Matern function with \(\nu=3/2\) </li>
<li>
covarflag==2 Uses Matern function with \(\nu=5/2\) </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">d2covar1d</td><td>The second derivative of the Covariance w.r.t. Xt </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00120">120</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="a34ae1208b87dd5a6ce817bfa04c127dc"></a><!-- doxytag: member="covars::d2covarfunc" ref="a34ae1208b87dd5a6ce817bfa04c127dc" args="(ndim, X, Xt, theta, d2k)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">subroutine covars::d2covarfunc </td>
          <td>(</td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ndim</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>Xt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim,ndim), intent(out)&#160;</td>
          <td class="paramname"><em>d2k</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Subroutine for computing the Hessian of the multidimensional covariance function. The second derivative is performed with respect to the second coordinate. </p>
<p>The multidimensional covariance is built up using a tensor product of 1 dimensional covariance functions: </p>
<p class="formulaDsp">
\[ k(\vec{X},\vec{X}&#39;; \theta) = \prod_{i}^{D} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \]
</p>
<p> where \(D\) is the dimension of the problem. The 1-D covariance functions are defined in function covar1d The derivative of this covariance with respect to the coordinate \( x_{j}\) can be written as: </p>
<p class="formulaDsp">
\[ \frac{\partial}{\partial x_{j}} k(\vec{X},\vec{X}&#39;; \theta) = \frac{d}{dx_{j}} k_{j} \left( \bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) \prod_{i \ne j} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right)\]
</p>
<p> The second derivative of the covariance with repect to the \(l\) component of the second coordinate \( x&#39;_{l}\) is given as: </p>
<p class="formulaDsp">
\[ \frac{\partial^{2}}{\partial x_{j} \partial x&#39;_{l}} k(\vec{X},\vec{X}&#39;; \theta) = \begin{cases} \frac{d^{2}}{dx_{j} dx&#39;_{j}} k_{j} \left( \bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) \prod_{i \ne j} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \text{ for $l=j$, } \\\ -\frac{d}{dx_{j}} k_{j} \left( \bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) \frac{d}{dx_{l}} k_{l} \left( \bigg \vert \frac{X_{l} - X&#39;_{l}}{\theta_{l}} \bigg \vert \right) \prod_{i \ne j \ne l} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \text{ for $l \ne j$} \end{cases} \]
</p>
<p> $ The entire Hessian can be computed efficiently by storing the following intermediate products as well as the 1-D covariance function values. Define the lower product as: </p>
<p class="formulaDsp">
\[ L_{j} = \prod_{i&lt;j} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \]
</p>
<p>, the upper product as: </p>
<p class="formulaDsp">
\[ U_{j} = \prod_{i&gt;j} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \]
</p>
<p> and the intermediate product as: </p>
<p class="formulaDsp">
\[ M_{l,j} = \prod_{l&lt;i&lt;j} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \]
</p>
<p>, the hessian of the covariance can be computed as: </p>
<p class="formulaDsp">
\[ \frac{\partial^{2}}{\partial x_{j} \partial x&#39;_{l}} k(\vec{X},\vec{X}&#39;; \theta) = \begin{cases} L_{j} \frac{d^{2}}{dx_{j} dx&#39;_{j}} k_{j} \left(\bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) U_{j} \text{ for $l=j$, } \\\ -L_{j} \frac{d}{dx_{j}} k_{j} \left( \bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) M{j,l} \frac{d}{dx_{l}} k_{l} \left( \bigg \vert \frac{X_{l} - X&#39;_{l}}{\theta_{l}} \bigg \vert \right) U_{l} \text{ for $l \ne j$} \end{cases} \]
</p>
<p>. The lower, upper and intermediate products can be built up recursively based on the stored 1-D covariance function values. This allows the full Hessian to be calculated in order \(D^{2}\) time. For the intermediate product, the diagonal and sub-diagonal is defined as: </p>
<p class="formulaDsp">
\[\begin{cases} M_{j,j} = 1 &amp; \text{for $j=1,..,D$, } \\\ M_{j,j+1} = 1 &amp; \text{for $j=1,..,D-1$, } \end{cases} \]
</p>
<p> Further cost savings are realized by utilizing the fact that the Hessian is symmetric. Hence, only the upper diagonal components of the Hessian are analytically computed and the result of this calculation is copied to the lower diagonal components. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood Department of Mechanical Engineering University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 3, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> ndim </b>: The dimension of the problem </td></tr>
    <tr><td class="paramname">in)</td><td><b> X </b>: Coordinates of the first point (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> Xt </b>: Coordinates of the second point (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> theta </b>: Length scale in each dimension </td></tr>
    <tr><td class="paramname">out)</td><td><b> dk </b>: Covariance value </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00300">300</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="af8df26f523fb00b229c1d37818ee3187"></a><!-- doxytag: member="covars::dcovar1d" ref="af8df26f523fb00b229c1d37818ee3187" args="(X, Xt, theta)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">real(8) function covars::dcovar1d </td>
          <td>(</td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>Xt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Function used to calculate the derivative of the one dimensional covariance functions with respect to the first coordinate. </p>
<p>This function calculates the derivative of the one dimensional Matern function with three possible values the parameter \( \nu \) (specified with the variable <em>covarflag</em>). The derivative is performed with respect to the first coordinate (<em>X</em>). This derivative is required for the covariance between function and derivative values: </p>
<p class="formulaDsp">
\[ cov(y, \frac{d y}{d x}) = \frac{d}{dx} k(X,X&#39;,\theta) \]
</p>
<p>. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood <br/>
 Department of Mechanical Engineering <br/>
 University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 17, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> X </b>: Coordinate of the first point </td></tr>
    <tr><td class="paramname">in)</td><td><b> Xt</b>: Coordinate of the second point </td></tr>
    <tr><td class="paramname">in)</td><td><b> </b>: Length scale in the dimension </td></tr>
    <tr><td class="paramname">in)</td><td><b>covarflag</b>: Flag to govern which covariance function is used (stored as global variable in this module) <br/>
 <ul>
<li>
covarflag==0 Uses Matern function with \(\nu=1/2\) </li>
<li>
covarflag==1 Uses Matern function with \(\nu=3/2\) </li>
<li>
covarflag==2 Uses Matern function with \(\nu=5/2\) </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">dcovar1d</td><td>the Derivative of the Covariance w.r.t. X </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00078">78</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="a0b0ed77b6fba9f79673cfa398b77b8d3"></a><!-- doxytag: member="covars::dcovarfunc" ref="a0b0ed77b6fba9f79673cfa398b77b8d3" args="(ndim, X, Xt, theta, dk)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">subroutine covars::dcovarfunc </td>
          <td>(</td>
          <td class="paramtype">integer, intent(in)&#160;</td>
          <td class="paramname"><em>ndim</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>X</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>Xt</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(in)&#160;</td>
          <td class="paramname"><em>theta</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">real(8), dimension(ndim), intent(out)&#160;</td>
          <td class="paramname"><em>dk</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Subroutine for computing the gradient of the multidimensional covariance function. </p>
<p>The multidimensional covariance is built up using a tensor product of 1 dimensional covariance functions: </p>
<p class="formulaDsp">
\[ k(\vec{X},\vec{X}&#39;; \theta) = \prod_{i}^{D} k_{i}\left(\bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right)\]
</p>
<p> where \(D\) is the dimension of the problem. The 1-D covariance functions are defined in function covar1d The derivative of this covariance with respect to the coordinate \( x_{j}\) can be written as: </p>
<p class="formulaDsp">
\[ \frac{\partial}{\partial x_{j}} k(\vec{X},\vec{X}&#39;; \theta) = \frac{d}{dx_{j}} k_{j} \left( \bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) \prod_{i \ne j} k_{i} \left(\bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right)\]
</p>
<p> Although conceptually easy, the above formula for the derivative of the covariance function is inefficient as the complexity is order \(D^{2}\). Using memoization, the gradient can be computed in order \(D\) time by computed and storing several intermediate products. Defining the lower product as: </p>
<p class="formulaDsp">
\[ L_{j} = \prod_{i&lt;j} k_{i} \left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \]
</p>
<p> and the upper product as: </p>
<p class="formulaDsp">
\[ U_{j} = \prod_{i&gt;j} k_{i}\left( \bigg \vert \frac{X_{i} - X&#39;_{i}}{\theta_{i}} \bigg \vert \right) \]
</p>
<p>, the derivative can be computed as: </p>
<p class="formulaDsp">
\[ \frac{\partial}{\partial x_{j}} = L_{j} \frac{d}{dx_{j}} k_{j} \left( \bigg \vert \frac{X_{j} - X&#39;_{j}}{\theta_{j}} \bigg \vert \right) U_{j} \]
</p>
<p> By storing the 1-D covariance function values, the upper and lower products can be built up recursively in order \(D\) time. The use of these upper and lower products allows for the re-use of work for each component of the gradient, reducing the cost of constructing the entire gradient. </p>
<dl class="author"><dt><b>Author:</b></dt><dd>Brian Lockwood Department of Mechanical Engineering University of Wyoming </dd></dl>
<dl class="date"><dt><b>Date:</b></dt><dd>May 3, 2012 </dd></dl>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">in)</td><td><b> ndim </b>: The dimension of the problem </td></tr>
    <tr><td class="paramname">in)</td><td><b> X </b>: Coordinates of the first point (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> Xt </b>: Coordinates of the second point (size=[ndim]) </td></tr>
    <tr><td class="paramname">in)</td><td><b> theta </b>: Length scale in each dimension </td></tr>
    <tr><td class="paramname">out)</td><td><b> dk </b>: Covariance value </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00218">218</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="aa9afe235deb03daa3ab99562f273a049"></a><!-- doxytag: member="covars::covarflag" ref="aa9afe235deb03daa3ab99562f273a049" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">integer <a class="el" href="classcovars.html#aa9afe235deb03daa3ab99562f273a049">covars::covarflag</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00014">14</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="a13b8005ed6d342aa9ffef7e63ae87ca2"></a><!-- doxytag: member="covars::root3" ref="a13b8005ed6d342aa9ffef7e63ae87ca2" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">real(8), parameter <a class="el" href="classcovars.html#a13b8005ed6d342aa9ffef7e63ae87ca2">covars::root3</a> = sqrt(3.d0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00015">15</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="ad0ecb51a9375ad09cba6e8014ba62eac"></a><!-- doxytag: member="covars::root5" ref="ad0ecb51a9375ad09cba6e8014ba62eac" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">real(8), parameter <a class="el" href="classcovars.html#ad0ecb51a9375ad09cba6e8014ba62eac">covars::root5</a> = sqrt(5.d0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00016">16</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<a class="anchor" id="ac23ea8267361ac7e7127b192e9d6b7a2"></a><!-- doxytag: member="covars::third" ref="ac23ea8267361ac7e7127b192e9d6b7a2" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">real(8), parameter <a class="el" href="classcovars.html#ac23ea8267361ac7e7127b192e9d6b7a2">covars::third</a> = 1.D0/3.D0</td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Definition at line <a class="el" href="covars_8f90_source.html#l00017">17</a> of file <a class="el" href="covars_8f90_source.html">covars.f90</a>.</p>

</div>
</div>
<hr/>The documentation for this module was generated from the following file:<ul>
<li><a class="el" href="covars_8f90_source.html">covars.f90</a></li>
</ul>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>
Copyright (C) 2012 Brian A. Lockwood <br>
Generated on Tue May 1 2012 17:15:55 for Kriging Library
by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer"
							 src="doxygen.png"
							 alt="doxygen"/></a>
1.7.3
</small></address>
